import sys

sys.path.append("..")
from utils import get_connection

# credient = pika.PlainCredentials(username='admin',password='admin') connection = pika.BlockingConnection(
# pika.ConnectionParameters(host='0.0.0.0',port=5672,virtual_host='/',credentials=credient))
connection = get_connection()
channel = connection.channel()

channel.exchange_declare(exchange='topic_exchange', exchange_type='topic', durable=True)

for i in range(10):
    message = f'time {i}'
    if i % 2 == 0:
        channel.basic_publish(exchange='topic_exchange', routing_key='like.you', body=message)
    else:
        channel.basic_publish(exchange='topic_exchange', routing_key='hate.you', body=message)
    print(message)
connection.close()
